<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
  <title>Jena 2 Ontology API - common programming problems</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="author" content="Ian Dickinson" />
    <meta name="description" content="" />
    <meta name="keywords" content="" />
    <link href="../styles/doc.css" rel="stylesheet" type="text/css" />
    <!--
      CVS: $Id: common-problems.html,v 1.10 2007/01/17 10:44:20 andy_seaborne Exp $
     (c) Copyright 2003, 2004, 2005, 2006, 2007 Hewlett-Packard Development Company LP
    -->
</head>

<body>
<h1 id="commonProblems">Common ontology application problems</h1>
<p>In this section, we cover some of the common questions or programming tasks 
  that have arisen when writing Jena ontology applications. Brief descriptions 
  of the sample programs are also given.</p>
<h3>Index</h3>
<ol>
  <li><a href="#aBox-tBox">Combining instance data and schemas (a-boxes and t-boxes)</a></li>
  <li><a href="#samplePrograms">Sample programs</a></li>
</ol>
<h2 id="aBox-tBox">Combining instance data and schemas (A-box and T-box separation)</h2>
<p>In description logic terminology, the <i>t-box</i> contains the axioms defining 
  the classes and relations in an ontology, while the <i>a-box</i> contains the 
  assertions about the individuals in the domain. The RDFS-based ontology languages 
  (RDFS, OWL, DAML+OIL) don't make a distinction between these two categories 
  of information: terminology and instance data may be freely mixed. However, 
  there are some situations in which it is useful to make the separation.</p>
<p>One particular use case for a-box an t-box distinctions is where the assertion 
  data is not directly associated with the terminology declarations. In OWL and 
  DAML+OIL, a document containing instance data can use the <i>imports</i> declaration 
  to indicate the source of the relevant class and property declarations. RDFS 
  does not have an equivalent of <i>imports</i>. There may be other situations 
  in which an OWL document, say, does not directly import the relevant supporting 
  ontologies.</p>
<p>To address this in Jena, we use a capability of the reasoner architecture to 
  separately bind t-box and a-box data sources. The reasoner is associated with 
  the t-box (class and property definitions), then applied to the a-box (instance 
  data). </p>
<p>Assume that the t-box and a-box data sources are specified by URI variables 
  <code>tBoxURI</code> and <code>aBoxURI</code> respectively. We first define 
  models to hold the data:</p>
<pre>Model tBox = ModelFactory.createDefaultModel();
tBox.read( tBoxURI );
Model aBox = ModelFactory.createDefaultModel();
aBox.read( aBoxURI );</pre>
<p> Then, we create a reasoner that will use these declarations:</p>
<pre>Reasoner reasoner = ReasonerRegistry.getOWLReasoner().bindSchema( tBox );</pre>
<p>Finally, we create an ontology model specification that includes this reasoner, 
  and use to build an ontology model with the a-box as the base model:</p>
<pre>OntModelSpec spec = new OntModelSpec( OntModelSpec.OWL_MEM_RULE_INF );
spec.setReasoner( reasoner );
OntModel m = ModelFactory.createOntologyModel( spec, aBox );</pre>
<p></p>
<h2 id="samplePrograms">Sample programs</h2>
<p>A number sample programs are included in the ontology documentation. These 
  are intended to illustrate approaches to commonly asked questions by users. 
  The intent with these programs is simply to illustrate the approach: they are 
  not intended to be complete solutions to the problem, since the exact requirements 
  for a given solution will depend on the application requirements.</p>
<p>Current example programs are:</p>
<ul>
  <li><a href="../examples/persistent-ont-model/index.html">using a persistent (database) 
    model with the ontology API</a></li>
  <li><a href="../examples/class-hierarchy/index.html">printing a listing of the 
    class hierarchy in a model</a></li>
  <li><a href="../examples/describe-class/index.html">generating a textual description 
    of an ontology class</a></li>
</ul>
<p>Further example programs may be added in future.</p>
</body>
</html>
